//
//  XDCelebrityController.m
//  XDEducation
//
//  Created by Ethan on 2017/5/15.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "XDCelebrityController.h"
#import "XDConstantHeaderFile.h"
#import "WebViewController.h"
#import "XDColorHeaderFile.h"
@interface XDCelebrityController ()
@property (nonatomic,strong) UIButton *oneButton;
@property (nonatomic,strong) UIButton *towButton;
@property (nonatomic,strong) UIButton *threeButton;
@property (nonatomic,strong) UIButton *fourButton;
@property (nonatomic,strong) UIButton *fiveButton;
@property (nonatomic,strong) UIButton *sixButton;
@property (nonatomic,strong) NSMutableArray *dataSource;
@end

@implementation XDCelebrityController


- (NSMutableArray *)dataSource {
    
    if (_dataSource == nil) {
        self.dataSource = [NSMutableArray array];
    }
    return _dataSource;
}




- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.titleStr;
    self.view.backgroundColor = [UIColor whiteColor];
    [self setUpSuperViews];
    
}

- (void)setUpSuperViews{
    
    UIView *grayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight *11/1334)];
    grayView.backgroundColor =  UIColor(232, 232, 234);
    [self.view addSubview:grayView];
    
    
    
    //安徒生
    self.oneButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.oneButton.frame = CGRectMake(0,kScreenHeight *44/1334,kScreenWidth/3,kScreenHeight *130/1334);
//    self.oneButton.backgroundColor = [UIColor redColor];
    [self.oneButton setImage:[UIImage imageNamed:@"antusheng"] forState:(UIControlStateNormal)];
    self.oneButton.tag = 201;
    [self.dataSource addObject:self.oneButton];
    [self.oneButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    [self.view addSubview:self.oneButton];
    
//    冰心
    self.towButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.towButton.frame = CGRectMake(self.oneButton.frame.origin.x + self.oneButton.frame.size.width,self.oneButton.frame.origin.y,self.oneButton.frame.size.width,self.oneButton.frame.size.height);
    [self.towButton setImage:[UIImage imageNamed:@"bingxin"] forState:(UIControlStateNormal)];
    self.towButton.tag = 202;
    [self.dataSource addObject:self.towButton];
    [self.towButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];

//    self.towButton.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:self.towButton];
    
//    几米
    self.threeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.threeButton.frame = CGRectMake(self.towButton.frame.origin.x + self.towButton.frame.size.width,self.towButton.frame.origin.y,self.towButton.frame.size.width,self.towButton.frame.size.height);
    [self.threeButton setImage:[UIImage imageNamed:@"jimi"] forState:(UIControlStateNormal)];
    self.threeButton.tag = 203;
    [self.dataSource addObject:self.threeButton];
    [self.threeButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];

//    self.threeButton.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.threeButton];
    
//    老舍
    self.fourButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.fourButton.frame = CGRectMake(self.oneButton.frame.origin.x, self.oneButton.frame.origin.y + self.oneButton.frame.size.height +  kScreenHeight *84/1334, self.oneButton.frame.size.width, self.oneButton.frame.size.height);
    [self.fourButton setImage:[UIImage imageNamed:@"laoshe"] forState:(UIControlStateNormal)];
    self.fourButton.tag = 204;
    [self.dataSource addObject:self.fourButton];
    [self.fourButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];

//    self.fourButton.backgroundColor = [UIColor greenColor];
    [self.view addSubview:self.fourButton];
    
//    鲁迅
    self.fiveButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.fiveButton.frame = CGRectMake(self.towButton.frame.origin.x, self.fourButton.frame.origin.y , self.towButton.frame.size.width, self.towButton.frame.size.height);
    [self.fiveButton setImage:[UIImage imageNamed:@"luxun"] forState:(UIControlStateNormal)];
    self.fiveButton.tag = 205;
    [self.dataSource addObject:self.fiveButton];
    [self.fiveButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];

//    self.fiveButton.backgroundColor = [UIColor blueColor];
    [self.view addSubview:self.fiveButton];
    
//    郑渊洁
    self.sixButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.sixButton.frame = CGRectMake(self.threeButton.frame.origin.x, self.fourButton.frame.origin.y , self.oneButton.frame.size.width, self.oneButton.frame.size.height);
    [self.sixButton setImage:[UIImage imageNamed:@"zhengyanjie"] forState:(UIControlStateNormal)];
    self.sixButton.tag = 206;
    [self.dataSource addObject:self.sixButton];
    [self.sixButton addTarget:self action:@selector(allAction:) forControlEvents:(UIControlEventTouchUpInside)];
//    self.sixButton.backgroundColor = [UIColor purpleColor];
    [self.view addSubview:self.sixButton];
    

    
    
}

#pragma mark ----方法的实现 
- (void)allAction:(UIButton *)sender{
    
    NSInteger tag = sender.tag;
    NSString *tilteStr;
    
    if (201 == tag) {
        tilteStr = @"安徒生";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MRMJ_ATS&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
    }else if (202 == tag){
        tilteStr = @"冰心";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MRMJ_BX&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
    }else if (203 == tag){
        tilteStr = @"几米";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MRMJ_JM&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
    }else if (204 == tag){
        tilteStr = @"老舍";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MRMJ_LS&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
    }else if (205 == tag){
        tilteStr = @"鲁迅";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MRMJ_LX&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
    }else if (206 == tag){
        tilteStr = @"郑渊洁";
        NSString *str = [[NSString alloc] initWithFormat:@"%@",Base@"bbsws.do?action=showalltopic&forumcode=XXDD_QDLY_MRMJ_ZYJ&pageNumber=1"];
        [self theURL:str titleStr:tilteStr];
        
    }
    
    
    
}

- (void)theURL:(NSString *)str titleStr:(NSString *)titleStr{
    
    WebViewController *web = [WebViewController new];
    web.str = str;
    web.nameTitle = titleStr;
    [self.navigationController pushViewController:web animated:YES];
}



@end
